<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file='base/common_header'}
    <style>
        .layui-table td, .layui-table th { min-width: auto; }
    </style>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="/admin">首页</a>
                <a href="/admin/topic">首页banner管理</a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-input-inline layui-show-xs-block">
                            <button type="button" class="layui-btn" onclick="xadmin.open('添加Banner','/admin/banner/add','','',true)">
                                <i class="layui-icon"></i>添加Banner</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>图片</th>
                            <th>测评ID</th>
                            <th>操作</th></tr>
                        </thead>
                        <tbody>
                        {volist name='list' id='topic'}
                        <tr>
                            <td>{$topic.id}</td>
                            <td><a href="{$topic.banner_img}" target="_blank" title="点击查看原图"><img src="{$topic.banner_img}" width="60px" height="60px"></a></td>
                            <td>{$topic.topic_id}</td>
                            <td class="td-manage">
                                <a title="编辑" onclick="xadmin.open('编辑','/admin/banner/edit/{$topic.id}','','',true)" href="javascript:;">
                                    <i class="layui-icon">&#xe63c;</i></a>
                                <a title="隐藏" onclick="topic_del(this,'{$topic.id}')" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i></a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
function topic_del(obj, id) {
    layer.confirm('确认要删除吗？',
        function(index) {
            //发异步删除数据
            $.post('/admin/banner/del',{id:id},function (data) {
                console.log(data)
                if(data.error_code == 0){
                    layer.msg('操作成功!', {
                        icon: 1,
                        time: 1000
                    },function () {
                        window.location.reload()
                    });
                }else{
                    layer.msg('操作失败!', {
                        icon: 1,
                        time: 1000
                    });
                }
            },"json")

        });
}


</script>

</html>